package com.afinal.intelligencetrash.ui.MapUtils;

import com.afinal.intelligencetrash.Model.bean.TrashStatusDo;
import com.afinal.intelligencetrash.R;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.MarkerOptions;

/**
 * Created by 厂里帅小伙 on 2/24 0024.
 */

public class MarkerDo {
    public static final int STATE_WELL = 3;
    public static final int STATE_NORMAL = 0;
    public static final int STATE_FULL = 1;
    public static final int STATE_DANGER = 2;
    public static final int STATE_FIRE = 4;
    private static final int FIRE_TEMP = 28;
    private double latitude;  //纬度
    private double longitude; //经度
    private String address;
    private int state;

    public TrashStatusDo getTrashStatusDo() {
        return trashStatusDo;
    }

    public void setTrashStatusDo(TrashStatusDo trashStatusDo) {
        this.trashStatusDo = trashStatusDo;
        switch (trashStatusDo.getContent()/10){
            case 10:
            case 9:
            case 8:
                state = STATE_WELL; break;
            case 7:
            case 6:
            case 5:
            case 4:
            case 3:
                state = STATE_NORMAL; break;
            case 2:
            case 1:
            case 0:
                state = STATE_FULL; break;
        }
        if(trashStatusDo.getSidu() > FIRE_TEMP){
            state = STATE_FIRE;
        }
    }

    private TrashStatusDo  trashStatusDo;

    public MarkerDo(double latitude, double longitude, String address) {
        this.latitude = latitude;
        this.longitude = longitude;
        this.address = address;
    }

    public long getTrashId() {
        return trashStatusDo.getId();
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getState() {
        return state;
    }



    public MarkerOptions initMarkerOptions(MarkerOptions options) {
        options.position(new LatLng(getLatitude(), getLongitude()));
        switch (getState()){
            case MarkerDo.STATE_WELL:{
                options.icon(BitmapDescriptorFactory.fromResource(R.drawable.trash_tag_well));
            } break;
            case MarkerDo.STATE_NORMAL:{
                options.icon(BitmapDescriptorFactory.fromResource(R.drawable.trash_tag_normal));
            } break;
            case MarkerDo.STATE_FULL:{
                options.icon(BitmapDescriptorFactory.fromResource(R.drawable.trash_tag_full));
            } break;
            case MarkerDo.STATE_FIRE:{
                options.icon(BitmapDescriptorFactory.fromResource(R.drawable.fire_tag));
            } break;
        }
        return options;
    }
}
